<?php
session_start(); //Do not remove this
    if ($_SESSION['login']!='123!@#'){
		header('location:index.php');
	}
	require "../libs/config.php";
	require "../libs/db_functions.php";
	$story_id =  isset($_POST['story_id'])? $_POST['story_id'] : 1;
	$story_table_name = 'story_id_'.$story_id;
	//exit();
	  CONNECT_DB();
		mysql_query("SET NAMES utf8");

		$sql="SELECT MAX(chapter_id) FROM $story_table_name";
		$result=mysql_query($sql);
		$value =  mysql_result($result, 0);
		if ($result){
			echo $value;
		} else {
			echo 'err - check your story id!';
		}
?>